﻿<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    

    <title>用户行为记录</title>
    
    <link rel="shortcut icon" href="favicon.ico">
	<link href="css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="css/font-awesome.min.css?v=4.4.0" rel="stylesheet">

    <!-- Data Tables -->
    <link href="css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <link href="js/plugins/layui/css/layui.css" rel="stylesheet">
    <link href="css/animate.min.css" rel="stylesheet">
    <link href="css/plugins/toastr/toastr.min.css" rel="stylesheet">
    <link href="css/style.min.css?v=4.0.0" rel="stylesheet" />

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title" style="height:72px;">
                        <div class="ibox-tools">
                            <a class="collapse-link" href="javascript:location.href=location.href;">
                                <i class="fa fa-refresh"></i>
                            </a>
                        </div>
                        <h5>基本 <small>分类/查找</small></h5>
						<div class="col-sm-12">
							<div class="col-sm-9">
								<form class="form-inline">
								<div class="input-group input-group-sm">
									<input id="username" type="text" class="form-control" placeholder="用户名"> 
								</div>
								<div class="input-group input-group-sm">
									<input id="startDate" type="text" class="form-control" placeholder="开始时间">
								</div>
								<div class="input-group input-group-sm">
									<input id="endDate" type="text" class="form-control" placeholder="结束时间"> 
								</div>
								<div class="input-group input-group-sm">
								 <button type="button" id="searchUserBehavior" class="btn btn-sm btn-primary search" style="margin-bottom:2px;">搜索</button>
								</div>
								</form>
							</div>
							<div class="col-sm-3 text-right">
							</div>
						</div>
                    </div>
                    <div class="ibox-content">

                        <table id="layTab" class="table table-striped table-bordered table-hover dataTables-example">
                            <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>账号</th>
                                    <th>角色</th>
                                    <th>IP</th>
                                    <th>事件</th>
                                    <th>请求路径</th>
                                    <th>请求方式</th>
				    <th>返回状态</th>
				    <th>请求耗时</th>
									<!--<th width="140">请求参数</th>-->
									<th width="140">请求时间</th>
                                </tr>
                            </thead>
                            <tbody>
                            </tbody>
							<tfoot>
							
							</tfoot>
                        </table>

                    </div>
                </div>
            </div>
        </div>
        
    </div>
    <script src="js/jquery.min.js?v=2.1.4"></script>
    <script src="js/bootstrap.min.js?v=3.3.5"></script>
	<script src="js/plugins/toastr/toastr.min.js"></script>
	<script src="js/plugins/layui/layui.js"></script>
	<script src="js/custom/layTool.js"></script>
    <script type="text/javascript" src="js/custom/app.js" charset="UTF-8"></script>
    <script type="text/javascript" src="js/custom/tools.js" charset="UTF-8"></script>
    <script>
	var pageSize = 10;
	var pageNumber = 1;
	function searchUserBehavior(pageNumber ,pageSize,username,startDate,endDate){
		var url = 'userBehavior/queryUserBehaviorByPage';
		jQuery.ajax({
			url:domain + url,
			type:"get",
			data:{"page":pageNumber,"pageSize":pageSize,
				  "username":username,"startDate":startDate,
				  "endDate":endDate},
			crossDomain:true,
			xhrFields:{
				withCredentials:true
			},
			success:function (data) {
				if(data.status == 200){
					var totalPage = data.data.total;//总页数
					pageNumber = data.data.page;//当前页
					var totalRow = data.data.records;//总条数
	   
					//拼凑html
					combHTML(data.data.rows);
					var arr = [username,startDate,endDate];
				   //分页
					LayPage('layTab',totalPage,totalRow,pageNumber ,pageSize,"searchUserBehavior",arr);
				}else{
					top.toastr.warning(data.msg);
				}
			},
			error:function(data) {
				top.toastr.error("查询列表失败，请检查网络");
			}
		})
		
	}
	
	function combHTML(data){
		var htmls = new Array();
		for (var i=0;i<data.length;i++){
			htmls.push('<tr class="gradeU">');
			htmls.push('		<td>'+ data[i].id +'</td>');
			htmls.push('		<td>'+ data[i].username +'</td>');
			htmls.push('		<td>'+ data[i].roleCode +'</td>');
			htmls.push('		<td>'+ data[i].clientIp + '（' + data[i].country + ',' + data[i].province + ',' + data[i].city +'）</td>');
			htmls.push('		<td>'+ data[i].operEvent +'</td>');
			htmls.push('		<td>'+ data[i].reqUrl +'</td>');
			htmls.push('		<td>'+ data[i].reqType +'</td>');
			//htmls.push('		<td>'+ data[i].reqParam +'</td>');
			htmls.push('		<td>'+ data[i].respStatus +'</td>');
			htmls.push('		<td>'+ data[i].useTime +'</td>');
			htmls.push('		<td>'+ data[i].operTime +'</td>');
			htmls.push('</tr>');
							
		}
		$("#layTab tbody").html(htmls.join(''));
		
	}
	
	$(function(){
		searchUserBehavior(pageNumber,pageSize,"","","");
		$("#searchUserBehavior").on("click",function(){
			searchUserBehavior(pageNumber,pageSize,$("#username").val(),$("#startDate").val(),$("#endDate").val());
		})
		
		layDate_start_end_dateTime('startDate','endDate');
	})
	
	
	</script>

	<script>	//=======   页面权限显示   ======//
	//当前菜单代码 (每个页面不一样，需要配置)
		var s_menuCode = "user_behavior";
	//所有可用权限
		var roleAuth = app.permission(s_menuCode);
	//当前菜单所有可用权限（排除被禁用的按钮）
		var menuAuth = app.menuButtonByOn(s_menuCode);
		
		drawBtn(roleAuth,menuAuth);
	</script>
</body>

</html>
